<template>

  <a-modal
    :title="title"
    :width="1000"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
	:maskClosable="false"
    cancelText="关闭"
  class="btn_none">

  <a-card :bordered="false">
    <div>
      <img :src="imageUrl" style="height: 100%;width: 100%;" />
    </div>
    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        bordered
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        @change="handleTableChange">

      </a-table>
    </div>
    <!-- table区域-end -->

  </a-card>

  </a-modal>
</template>

<script>
  /*import ModelModal from './modules/ModelModal'*/
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction,deleteAction,putAction,postAction} from '@/api/manage'

  export default {
    name: "HistoryList",
    mixins:[JeecgListMixin],
    components: {
      /*ModelModal,*/
      /*ModelEditModal*/
    },
    data () {
      return {
        description: '历史审核页面',
        paramId:"",
        title:"操作",
        visible: false,
        confirmLoading: false,
        imageUrl: '',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },

		   /*{
            title: '模型ID',
            align:"center",
            dataIndex: 'id'
           },*/
          /*{
            title: '标题',
            align:"center",
            dataIndex: 'title'
          },*/
		      {
            title: '任务名称',
            align:"center",
            dataIndex: 'name'
           },
          /*{
            title: '申请人',
            align:"center",
            dataIndex: 'userName'
          },
          {
            title: '委托人',
            align:"center",
            dataIndex: 'task.owner'
          },*/
          {
            title: '处理人',
            align:"center",
            dataIndex: 'assigneeName'
          },
          {
            title: '耗时',
            align:"center",
            dataIndex: 'duration',
            customRender:function (t,r,index) {
              const duration = r.duration
              var text = ''
              if (duration != null) {
                // text = (duration / 1000 / 60).toFixed(2)
                // return text;
                var text = "";
                var days = Math.floor(duration / (24 * 60 * 60 * 1000));
                if(days != 0){
                  text += days + "天";
                }
                //计算小时数
                var hourLevel = duration % (24 * 60 * 60 * 1000);
                var hours = Math.floor(hourLevel / (60 * 60 * 1000))
                if(hours != 0){
                  text += hours + "小时";
                }
                //计算分钟数
                var minutesLevel = hourLevel % (60 * 60 * 1000);
                var minutes = Math.floor(minutesLevel / (60 * 1000));
                if(minutes != 0){
                  text += minutes + "分";
                }
                //计算秒数
                var seconds = Math.round((minutesLevel % (60 * 1000)) / 1000);
                text += seconds + "秒";

                return text;
              }
              return text;
            }
          },
          {
            title: '开始时间',
            align:"center",
            dataIndex: 'startTime'
          },
          {
            title: '结束时间',
            align:"center",
            dataIndex: 'endTime'
          },
          {
            title: '审批结果',
            align:"center",
            dataIndex: 'taskFlow',
            customRender:function (t,r,index) {
              if(t == '1'){
                return '通过'
              }else if(t == '0'){
                return '未通过'
              }
              return t
            }
          },
          {
            title: '审批意见',
            align:"center",
            dataIndex: 'comment'
          }
          /*{
            title: '审批结果',
            align:"center",
            dataIndex: 'comment'
          },
          {
            title: '耗时',
            align:"center",
            dataIndex: 'actHiTaskinst.duration'
          },
          {
            title: '创建时间',
            align:"center",
            dataIndex: 'tactHiTaskinst.createTime'
          },*/
          /*{
            title: '当前任务节点',
            align:"center",
            dataIndex: 'key'
          },*/
          /*{
            title: '版本',
            align:"center",
            dataIndex: 'version'
          },
          {
            title: '部署时间',
            align:"center",
            dataIndex: 'deployTime'
          },*/
		   /*{
            title: '模型分类',
            align:"center",
            dataIndex: 'category'
           },*/

          /*{
            title: '模型描述',
            align:"center",
            dataIndex: 'description'
          },*/
		   /*{
            title: 'createTime',
            align:"center",
            dataIndex: 'createTime'
           },*/
		   /*{
            title: 'lastUpdateTime',
            align:"center",
            dataIndex: 'lastUpdateTime'
           },
		   {
            title: 'version',
            align:"center",
            dataIndex: 'version'
           },
		   {
            title: 'metaInfo',
            align:"center",
            dataIndex: 'metaInfo'
           },
		   {
            title: 'deploymentId',
            align:"center",
            dataIndex: 'deploymentId'
           },
		   {
            title: 'editorSourceValueId',
            align:"center",
            dataIndex: 'editorSourceValueId'
           },
		   {
            title: 'editorSourceExtraValueId',
            align:"center",
            dataIndex: 'editorSourceExtraValueId'
           },
		   {
            title: 'tenantId',
            align:"center",
            dataIndex: 'tenantId'
           },*/
          /*{
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }*/
        ],
		url: {
          list: "/act/taskinst/history/task/"+this.paramId,
          /*delete: "/act/model/delete",
          deleteBatch: "/act/model/deleteBatch",
          exportXlsUrl: "model/model/exportXls",
          importExcelUrl: "model/model/importExcel",*/
       },
        addModel:true,
        modelSrc:'',
    }
  },
  computed: {
    /*importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }*/
  },
    methods: {

      init (id) {
        this.visible = true;
        //alert(id);
        this.paramId = id;
        this.loadList();
        // 流程图
        // var url = process.env.VUE_APP_URL+`/handle/process/trace/auto/` + id + '?' + this.getRandomInt(0,100000);
        // this.imageUrl = url
        getAction("/handle/getPic/"+id, {}).then((res) => {
            this.imageUrl = "data:image/png;base64,"+res;
        })
      },
      getRandomInt(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
      },

      handleCancel () {
        this.close()
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      loadList() {
        //var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction("/act/taskinst/history/task/"+this.paramId, {}).then((res) => {
          if (res.success) {
            this.dataSource = res.result;
            //this.ipagination.total = res.result.total;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      },
      getYMDHMS(dateInterval) {
        //计算出相差天数
        var days = Math.floor(dateInterval / (24 * 60 * 60 * 1000));
        //计算小时数
        var hourLevel = dateInterval % (24 * 60 * 60 * 1000);
        var hours = Math.floor(hourLevel / (60 * 60 * 1000))
        //计算分钟数
        var minutesLevel = hourLevel % (60 * 60 * 1000);
        var minutes = Math.floor(minutesLevel / (60 * 1000));
        //计算秒数
        var seconds = Math.round((minutesLevel % (60 * 1000)) / 1000);
        return '天数 ' + days + ' 小时数 ' + hours + ' 分钟数 ' + minutes + ' 秒数 ' + seconds;
      }
      /*editModel(row){
        /!*this.modelSrc=window._CONFIG['domianURL']+'/modeler.html?modelId='+row.id;
        this.addModel=true;*!/
        let url =window._CONFIG['domianURL']+'/modeler.html?modelId='+row.id;
        window.open(url);
      },
      deployModel(row){
        const that = this;

        this.$confirm({
          title: "提示",
          content: "请确认点击了左上角的保存按钮?",
          onOk: function () {
            that.loading = true;
            getAction("/act/model/deploy/",{id:row.id}).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
              }else{
                that.$message.warning(res.message)
              }
            });
          }
        });


      },*/


    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>
<style lang="less">
  .btn_none{
    .ant-modal-footer{
      display: none;
    }
  }
</style>